home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / cycleIntermediateObjectSibli < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.4 KB  |  131 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //    Alias|Wavefront Script File
  19. //    MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //    Creation Date:  13 April 1997
  22. //    Author:         ms
  23. //
  24. //  Procedure Name:
  25. //      cycleIntermediateObjectSibling
  26. //
  27. //  Description:
  28. //        For the shapes under a single transform where only one is
  29. //      non-intermediate object and the other ones are - "cycle"
  30. //      through them so that 
  31. //
  32. //  Input Arguments:
  33. //      modifySelection - if set, the selection list is modified
  34. //                        to replace previously non-intermediate object
  35. //                        with a new non-intermediate object.
  36. //
  37. //  Return Value:
  38. //      None.
  39. //
  40.  
  41.  
  42. proc string getTheTransform( string $item )
  43. {
  44.     string $result = $item;
  45.     string $tmp[] = `ls -tr $result`;
  46.     if( size($tmp) == 0 ) {
  47.         $tmp = `listRelatives -p $result`;
  48.         if( size($tmp) > 0 ) {
  49.             $result = $tmp[0];
  50.         }
  51.     }
  52.     return $result;
  53. }
  54.  
  55. proc string needTheLeadTransform()
  56. {
  57.     string $result = "";
  58.     string $tmp[] = `ls -l -sl -tail 1 -type dagNode`;
  59.     if( size($tmp) > 0 ) {
  60.         $result = getTheTransform( $tmp[0] );
  61.     }
  62.     else {
  63.         $tmp = `ls -l -sl -tail 1`;
  64.         if( size($tmp) > 0 ) {
  65.             $tmp = `listRelatives -p $tmp[0]`;
  66.             if( size($tmp) > 0 ) {
  67.                 $result = getTheTransform( $tmp[0] );
  68.             }
  69.         }
  70.     }
  71.     return $result;
  72. }
  73.  
  74. proc doModifySelection( string $oldVers, string $newVers )
  75. {
  76.     string $act[] = `ls -sl`;
  77.     int $i, $n;
  78.     $n = size($act);
  79.     for( $i=0; $i<$n; $i+=1 ) {
  80.         $act[$i] = `substitute ($oldVers +"$") $act[$i] $newVers`;
  81.         $act[$i] = `substitute ($oldVers +"\\.") $act[$i] ($newVers + ".")`;
  82.     }
  83.  
  84.     select -cl;
  85.     for( $i=0; $i<$n; $i+=1 ) {
  86.         select -add $act[$i];
  87.     }
  88. }
  89.  
  90. global proc cycleIntermediateObjectSibling( int $modifySelection )
  91. {
  92.     string $parent = `needTheLeadTransform`;
  93.     if( $parent != "" ) {
  94.         int $oldVisShape = -1;
  95.         int $newVisShape = -1;
  96.         int $i, $n, $val, $cntr;
  97.         string $shapes[] = `listRelatives -s $parent`;
  98.         string $tmp;
  99.  
  100.         // Now, we want only one
  101.         $cntr = 0;
  102.         $n = size($shapes);
  103.         if( $n > 1 ) {
  104.             for( $i=0; $i<$n; $i+=1 ) {
  105.                 $val = `getAttr ($shapes[$i] + ".io")`;
  106.                 if( ! $val ) {
  107.                     $oldVisShape = $i;
  108.                     $cntr += 1;
  109.                 }
  110.             }
  111.  
  112.             if( 1 == $cntr ) {
  113.                 $newVisShape = $oldVisShape + 1;
  114.                 if( $newVisShape >= $n ) {
  115.                     $newVisShape = 0;
  116.                 }
  117.  
  118.                 if( ($oldVisShape >= 0) && ($newVisShape >= 0) ) {
  119.                     setAttr ($shapes[$oldVisShape] + ".io") true;
  120.                     setAttr ($shapes[$newVisShape] + ".io") false;
  121.  
  122.                     if( $modifySelection ) {
  123.                         doModifySelection( $shapes[$oldVisShape],
  124.                                            $shapes[$newVisShape] );
  125.                     }
  126.                 }
  127.             }
  128.         }
  129.     }
  130. }
  131.